package com.eric.rabbit.config;

import com.eric.rabbit.entity.work.WorkReceiver;
import com.eric.rabbit.entity.work.WorkSender;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author:Eric
 * @date:2021/6/28
 * 一个生产者 -> 一个队列 -> 两个消费者，两个消费者竞争消费消息
 */
@Configuration
public class WorkRabbitConfig {

    @Bean
    public Queue workQueue(){
        return new Queue("work.queue");
    }

    @Bean
    public WorkSender workSender(){
        return new WorkSender();
    }

    @Bean
    public WorkReceiver workReceiver1(){
        return new WorkReceiver(1);
    }

    @Bean
    public WorkReceiver workReceiver2(){
        return new WorkReceiver(2);
    }
}
